package linked_list

type tListIterator struct {
	items []interface{}
	count int
	pos int
}

func newListIterator(items []interface{}) IListIterator {
	size := len(items)
	copy := make([]interface{}, size)
	for i,it := range items {
		copy[i] = it
	}

	return &tListIterator{
		items: copy,
		count: size,
		pos: 0,
	}
}


func (me *tListIterator) More() bool {
	return me.pos < me.count
}

func (me *tListIterator) Next() (error,interface{}) {
	if me.pos >= me.count {
		return gIndexOutofBoundsError, nil
	}

	n := me.pos
	me.pos++
	return nil, me.items[n]
}